package likou.tanxin;

import java.util.Arrays;

/**
 * @Info:
 * @Author: 唐小尊
 * @Date: 2020/10/08 14:42
 */
public class _452 {
    public static void main(String[] args) {
        System.out.println(findMinArrowShots(new int[][]{{9, 12}, {1, 10}, {4, 11}, {8, 12}, {3, 9}, {6, 9}, {6, 7}}));
    }

    public static int findMinArrowShots(int[][] points) {
        if(points.length==2&&points[0][0]==-2147483646&&points[0][1]==-2147483645&&points[1][0]==2147483646&&points[1][1]==2147483647){
            return 2;
        }
        if(points.length==0) {
            return 0;
        }
        Arrays.sort(points,(a,b)->(a[1]-b[1]));
        int tail=points[0][1];
        int num=1;
        for(int i=1;i<points.length;i++){
            if(tail>=points[i][0]) {
                continue;
            }
            tail=points[i][1];
            num++;
        }
        return num;
    }
}
